package com.google.code.netbuilder.dal.entities;

import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

@XmlType(propOrder = {"id", "name", "type", "address", "isBroken", 
                        "isReserved", "numberOfPorts"}, 
                         name = "Equipment")
@XmlAccessorType(XmlAccessType.FIELD)
@Entity
@Table(name = "Equipment")
@SequenceGenerator(name="seq", initialValue=1, allocationSize=100)
public class Equipment {

        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
	Integer id;
	String name;
	String type;
	String address;
	int isBroken;
	int isReserved;
        @Column(name="number_of_ports")
	Integer numberOfPorts;
        @Temporal(javax.persistence.TemporalType.DATE)
	Date date;
//        @OneToMany(cascade = CascadeType.REMOVE)
//        Collection<Port> ports;
	
	public Date getDate() {
		return date;
	}

	public void setDate(long millisecond) {
		this.date = new Date(millisecond);
	}
	
	public void setDate(Date date) {
		this.date = date;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getIsBroken() {
		return isBroken;
	}

	public void setIsBroken(int isBroken) {
		this.isBroken = isBroken;
	}

	public int getIsReserved() {
		return isReserved;
	}

	public void setIsReserved(int isReserved) {
		this.isReserved = isReserved;
	}

	public Integer getNumberOfPorts() {
		return numberOfPorts;
	}

	public void setNumberOfPorts(Integer numberOfPorts) {
		this.numberOfPorts = numberOfPorts;
	}
}
